<template>
  <div class="container">
     <!-- 预览框 -->
     <el-dialog title="预览文章" :visible="closePreviewDialog" width="43%" @close="closePreview">
      <!-- 主体区域 -->
      <div class="preview-box">
        <div class="preview-title">{{ previewList.title }}</div>
        <div class="preview-nav">
          <!-- <span>{{ editArtical.createTime }}</span> -->
          <span>{{ previewList.createTime?.substring(0, previewList?.createTime .indexOf('.')).replace('T', ' ') }}</span>
          <span>{{ previewList.username }}</span>
          <span class="el-icon-view"></span>
          <span>{{ previewList.visits }}</span>
        </div>
        <div class="preview-content" v-html="previewList.articleBody"></div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    previewList: {
      type: Object
    },
    closePreviewDialog: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    closePreview () {
      this.$emit('update:closePreviewDialog', false)
    }
  }
}
</script>

<style scoped lang='scss'>
.preview-box {
  .preview-title {
    font-size: 25px;
    font-weight: 700;
    margin-bottom: 10px;
  }
}
.preview-nav {
    span {
      margin-right: 10px;
    }
  }
  .preview-content {
    margin-top: 10px;
    padding: 10px;
    background-color: #f5f5f5;
    border-top: 1px dashed #ccc;
  }
</style>
